package me.victor.jetpackcompose

import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.BaselineShift
import androidx.compose.ui.text.withStyle

/**
 * @author song.zheng
 * @create 2024/3/13
 * @description SuperscriptSubscriptText
 */
@Composable
fun SuperScriptText(normalText: String, scriptText: String) {
    Text(text = buildAnnotatedString {
        withStyle(style = SpanStyle(fontSize = MaterialTheme.typography.titleLarge.fontSize)) {
            append(normalText)
        }
        withStyle(
            style = SpanStyle(
                fontSize = MaterialTheme.typography.titleSmall.fontSize,
                fontWeight = FontWeight.Normal,
                baselineShift = BaselineShift.Superscript
            )
        ) {
            append(scriptText)
        }
    })
}